/**************************************************************************************************
*  Filename:       sensor_mpu6500.h
*  Revised:        $Date: 2014-02-05 10:47:02 +0100 (on, 05 feb 2014) $
*  Revision:       $Revision: 12066 $
*
*  Description:    Driver for the Invensys MPU6500 Motion Processing Unit
*
*  Copyright (C) 2014 - 2015 Texas Instruments Incorporated - http://www.ti.com/
*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*    Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
*
*    Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
*
*    Neither the name of Texas Instruments Incorporated nor the names of
*    its contributors may be used to endorse or promote products derived
*    from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************************/
#ifndef SENSOR_MPU6500_H
#define SENSOR_MPU6500_H

#ifdef __cplusplus
extern "C" {
#endif

/* ------------------------------------------------------------------------------------------------
 *                                          Includes
 * ------------------------------------------------------------------------------------------------
 */
#include "stdint.h"
#include "stdbool.h"

/* ------------------------------------------------------------------------------------------------
 *                                          Constants
 * ------------------------------------------------------------------------------------------------
 */
#define ACC_RANGE_2G       1
#define ACC_RANGE_4G       2
#define ACC_RANGE_8G       3
#define ACC_RANGE_16G      4
#define ACC_RANGE_INVALID  255
  
#define MPU_NO_AXIS        0x00
#define MPU_ALL_AXIS       0x07
   
#define MPU_DATA_READY     0x01
#define MPU_MOVEMENT       0x40
  
/* ------------------------------------------------------------------------------------------------
 *                                           Typedefs
 * ------------------------------------------------------------------------------------------------
 */


/* ------------------------------------------------------------------------------------------------
 *                                          Functions
 * ------------------------------------------------------------------------------------------------
 */
bool sensorMpu6500Init(void);
bool sensorMpu6500IntEnable(bool enable);
bool sensorMpu6500WomEnable(void);
uint8_t sensorMpu6500IntStatus(void);
bool sensorMpu6500Test(void);

void sensorMpu6500AccEnable(uint8_t config);
bool sensorMpu6500AccSetRange(uint8_t range);
bool sensorMpu6500AccRead(uint16_t *rawData);
float sensorMpu6500AccelConvert(int16_t rawValue);

void sensorMpu6500GyroEnable(uint8_t config);
bool sensorMpu6500GyroRead(uint16_t *rawData);
float sensorMpu6500GyroConvert(int16_t rawValue);

// For test 
uint8_t sensorMpu6500ReadRegs(uint8_t *data, uint8_t start, uint8_t nRegs);

/**************************************************************************************************
*/

#ifdef __cplusplus
};
#endif

#endif

/**************************************************************************************************
*/
